package com.sunfeng.fx;

import com.sunfeng.TimeUtils;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * @author sunfeng
 * @date 2021/03/04 18:13
 **/
@Slf4j(topic = "c.Test1")
public class Test2 {
    static int r1 = 0;
    static int r2 = 0;
    public static void main(String[] args) throws InterruptedException {
        test2();
    }

    public static void test2() throws InterruptedException {
        Thread t1 = new Thread(() -> {
            TimeUtils.sleep(1);
            r1 = 10;
        });
        Thread t2 = new Thread(() -> {
            TimeUtils.sleep(2);
            r2 = 20;
        });
        long start = System.currentTimeMillis();
        t1.start();
        t2.start();
        t2.join();
        t1.join();

        long end = System.currentTimeMillis();
        log.debug("r1: {} r2: {} cost: {}", r1, r2, end - start);
    }
}
